package com.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.ChapterDAO;
import com.pojo.Chapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@SuppressWarnings("ALL")
@Service
public class ChapterService extends ServiceImpl<ChapterDAO,Chapter> {

    @Autowired
    private ChapterDAO chapterDAO;

    /**
     * 查询对应科目章节
     * @param id  科目id
     * @return
     */
    public List<Chapter> findChapter(Integer id){
        QueryWrapper queryWrapper=new QueryWrapper();
        List<Chapter> list=null;
        if(id!=null){
            queryWrapper.eq("subject_id",id);
            //根据 科目id 查科目中的章节
            list=chapterDAO.selectList(queryWrapper);
        }
        return list;
    }
}
